package day1;

import day1.dao.IUserDao;
import day1.entity.User;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import util.Util;

public class ITest {
    SqlSession session;
    @Before
    public void init(){
        session= Util.getSession();
    }
    @After
    public void close(){
        session.commit();
        session.close();
    }

    @Test
    public void query1(){
        IUserDao dao=session.getMapper(IUserDao.class);
        System.out.println(dao.selectById(1));
    }
    @Test
    public void query2(){
        IUserDao dao=session.getMapper(IUserDao.class);
        System.out.println(dao.selectByNameAndId("hello",1));
    }
    @Test
    public void query3(){
        IUserDao dao=session.getMapper(IUserDao.class);
        User u=new User();
        u.setName("hello");
        u.setId(1);
        System.out.println(dao.selectByNameAndId2(u));
    }
    @Test
    public void query4(){
        IUserDao dao=session.getMapper(IUserDao.class);
        System.out.println(dao.selectByNameAndId3("hello",1));
    }
}
